//
//  MainDetailNoPicCell.m
//  Daybook
//
//  Created by dllo on 16/5/26.
//  Copyright © 2016年 zhangbin. All rights reserved.
//

#import "MainDetailNoPicCell.h"
#import "Common.h"

@interface MainDetailNoPicCell ()

@property (nonatomic, strong)UIView *lineView;

@property (nonatomic, strong)UIImageView *pointImageView;




@end

@implementation MainDetailNoPicCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];


        
    }
    return self;
}

- (void)createView {
    
    self.contentView.backgroundColor = [UIColor whiteColor];
    
    self.lineView = [[UIView alloc]init];
    self.lineView.backgroundColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.lineView];
    
    
    self.pointImageView = [[UIImageView alloc]init];
    self.pointImageView.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.pointImageView];
    self.pointImageView.image = [UIImage imageNamed:@"pointImage"];
    
    
    self.dateLabel = [[UILabel alloc]init];
    self.dateLabel.backgroundColor= [UIColor whiteColor];
    [self.contentView addSubview:self.dateLabel];
    self.dateLabel.font = [UIFont systemFontOfSize:12];
    self.dateLabel.textAlignment = 2;
    
    
    self.picImageView = [[UIImageView alloc]init];
    self.picImageView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.picImageView];
    
    
    self.nameLabel = [[UILabel alloc]init];
    self.nameLabel.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.nameLabel];
    self.nameLabel.font = [UIFont systemFontOfSize:12];
    
    
    
    
    
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.lineView.frame = CGRectMake(MAIN_WIDTH / 2, 0, 1, MAIN_HEIGHT);
    self.pointImageView.frame = CGRectMake(MAIN_WIDTH / 2 - 9, MAIN_HEIGHT / 2 - 40 / 414.0 *MAIN_WIDTH, 20 / 414.0 *MAIN_WIDTH, 20 / 414.0 *MAIN_WIDTH);
    
    self.picImageView.frame = CGRectMake(MAIN_WIDTH / 2 - 20 / 414.0 *MAIN_WIDTH, MAIN_HEIGHT / 2 - 20 / 414.0 *MAIN_WIDTH, 40 / 414.0 *MAIN_WIDTH, 40 / 414.0 *MAIN_WIDTH);
    self.dateLabel.frame = CGRectMake(MAIN_WIDTH / 2 - 50, MAIN_HEIGHT / 2 - 40 / 414.0 *MAIN_WIDTH, 40 / 414.0 *MAIN_WIDTH, 20 / 414.0 *MAIN_WIDTH);
    
    self.nameLabel.frame = CGRectMake(MAIN_WIDTH / 2 - 40 / 414.0 *MAIN_WIDTH, MAIN_HEIGHT / 2 + 20 / 414.0 *MAIN_WIDTH, 80 / 414.0 *MAIN_WIDTH, 20 / 414.0 *MAIN_WIDTH);
    
}

- (void)setAccountBook:(Account *)accountBook {
    _accountBook = accountBook;
    self.picImageView.image = [UIImage imageNamed:_accountBook.picName];
    self.dateLabel.text = [NSString stringWithFormat:@"%@日", [[NSString stringWithFormat:@"%@", _accountBook.time ] substringWithRange:NSMakeRange(8, 2)]];
    if (_accountBook.money == 0) {
        self.nameLabel.text = [NSString stringWithFormat:@"%@ %.2lf", _accountBook.name, [_accountBook.income floatValue]];
    }else {
        self.nameLabel.text = [NSString stringWithFormat:@"%@ %.2lf", _accountBook.name, [_accountBook.money floatValue]];
    }
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
